const create = async payload => {
	const {
		title,
		content,
		imgs,
		topic_ids
	} = payload
	
	// clientDB
	 
	 const db = uniCloud.database();
	 const posts = db.collection("posts");
	 
	 const res = await posts.add({
		 title,
		 content,
		 imgs,
		 topic_ids
	 })
	
	return res;
}


const praise = async payload => {
	const { uid, postID,praiseStatus } = payload
	
	const res = await uniCloud.callFunction({
		name: 'index',
		data: {
			action: 'post/praise',
			data: {
				 uid,
				  postID,
				  praiseStatus 
			}
		}
	})
	
	return res
}


const love = async payload => {
	const { uid, postID,loveStatus } = payload
	
	const res = await uniCloud.callFunction({
		name: 'index',
		data: {
			action: 'post/love',
			data: {
				 uid,
				  postID,
				  loveStatus 
			}
		}
	})
	
	return res
}

export default {
	create,
	praise,
	love
}